#ifdef WIN32
	#include"..\afx.h"
#else
	#include "../afx.h"
#endif
#include"GrammarExpression.h"
#include<iostream>
using std::cerr;
using std::endl;

bool GrammarExpression::Match(const string& token){
	if(this->IsEnd()){
		return false;
	}
	int size = token.size();

	int temp = this->Token;

	for(int i = 0 ; i < size; ++i,++temp){
		if(this->str[temp] == token[i]){
			continue;
		}
		else{
			return false;
		}
	}

	this->Token += size; 
	return true;
}

void GrammarExpression::Error(const char* const message){
	Debug::Error(message,*this);
}
void Debug::Error(const char * const message,const GrammarExpression& express){
	cerr <<"error: " << message << " at index " << express.Token << endl;	
}

void Debug::Log(const char* const message,const GrammarExpression& express){
	//to do nothing;
}


